package com.ruyichuxing.base;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.widget.Toast;

import com.ruyichuxing.eyepetizer.R;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

/**
 * Created by lenovo on 2017/9/6 16:51.
 * <p>
 * Eyepetizer
 * <p>
 * com.ruyichuxing.base
 */

public abstract class ToolbarActivity extends RxAppCompatActivity {


	public Toolbar toolbar;
	public ActionBar ab;
	private int layoutId;


	@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(getLayoutId());
		toolbar = (Toolbar) findViewById(R.id.toolbar);
		setSupportActionBar(toolbar);
		ab = getSupportActionBar();
		if (ab != null)
			ab.setDisplayHomeAsUpEnabled(true);
		initView();

		initData();
	}

	/**
	 * 初始化布局
	 *
	 * @return
	 */
	public abstract int getLayoutId();

	/**
	 * 初始化布局中的控件
	 */
	protected abstract void initView();


	/**
	 * 初始化数据
	 */
	protected abstract void initData();

	public void toSearch(Activity context) {
		Toast.makeText(context, "-----", Toast.LENGTH_SHORT).show();

//		Intent intent = new Intent(context, SearchActicity.class);
//		startActivity(intent);
	}
}
